package com.decent.ejfadmin.user.controller;

import com.decent.ejfadmin.common.bean.MessageBean;
import com.decent.ejfadmin.common.bean.Page;
import com.decent.ejfadmin.common.bean.RecommendUser;
import com.decent.ejfadmin.user.service.RecommendUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;

/**
 * 查询推荐返利用户
 *
 * @author weicx
 * @date 2018/07/28
 */
@RestController
@RequestMapping("RecommendUserController")
@Slf4j
public class RecommendUserController {
    @Autowired
    private RecommendUserService recommendUserService;

    @RequestMapping("queryRecommendUser")
    public Page queryRecommendUser(RecommendUser recommendUser, Page page, String startTime, String endTime) {
        try {
            return recommendUserService.queryRecommendUser(recommendUser, page, startTime, endTime);
        } catch (Exception e) {
            log.warn("[{}]查询推荐返利用户异常[{}]", recommendUser, e);
            page.setQueryBean(MessageBean.fail("查询出错:("));
            page.setResultList(Collections.emptyList());
            page.setTotal(0);
            return page;
        }
    }

}
